const common = require('lib/utils/common.js');
const db = require('db/reservation.js');

/** @name 预约列表 **/
exports.list = async ctx => {
	const options = {
		...common.YD_getPageDefault(ctx),
	}
	const totalRes = await db.yd_count(options);
  const total = totalRes[0].count || 0;
  const rows = await db.yd_list(options);
	ctx.success({
    total,
    rows
  });
};

/** @name 删除预约 **/
exports.delete = async ctx => {
	if(ctx.requiredParams(['id'])) return;
	const { id } = ctx.request.body;
	await db.yd_delete(id);
	ctx.success('预约删除成功');
};
